package com.jjsc.client.api.factory;

import com.jjsc.client.api.RemoteUserInfoService;
import com.jjsc.client.api.domain.UpdateUserLogin;
import com.jjsc.client.api.domain.UserInfo;
import com.jjsc.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @Author: 钟城明
 * @CreateTime: 2025-10-16
 * @Description:
 * @Version: 1.0
 */
@Slf4j
public class RemoteUserInfoFallbackFactory implements FallbackFactory<RemoteUserInfoService> {

    @Override
    public RemoteUserInfoService create(Throwable cause) {
        log.error("用户服务调用失败:{}", cause.getMessage());
        return new RemoteUserInfoService() {
            @Override
            public R<Boolean> register(UserInfo userInfo,  String source) {
                return R.fail("用户注册失败" + cause.getMessage());
            }

            @Override
            public R<UserInfo> getUserInfo(String username,  String source) {
                return R.fail("根据用户名获取用户信息" + cause.getMessage());
            }

            @Override
            public R<Boolean> updateUserLogin(UpdateUserLogin updateUserLogin, String source) {
                return R.fail("更新登录信息失败" + cause.getMessage());
            }
        };
    }
}
